﻿<%@ Page Language="C#" MasterPageFile="~/Design/MasterPage/MasterPage.master" AutoEventWireup="true" CodeFile="UrgencyForm.aspx.cs" Inherits="App_Input_UrgencyForm"   Title=""%>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
 getNewMessage('');            
function getNewMessage() {
            var e;            
            try {
                CommonAjaxUtils.FindAlarm("",bindCallBackResult_Message);
          
		    }
            catch(e) {
                alert('getNewMessage: '+e.message);
            }
        }
        
        function bindCallBackResult_Message(response) {    
            try {              
                                     
                setTimeout("getNewMessage('')", 10000);            
          
                                                                  
                var targetData = response.value;               		    		        		        		        
                var msgTable;
    	     // alert(targetData.length);
    	        // refresh top tool bar
	            if (targetData != null 
	                && typeof(targetData) == "object" 
	                && targetData.length > 0) {
	           
	                msgTable = document.getElementById("tbAlarm");
	                bindMsgTable(msgTable,targetData);
	                
	               

	            }
	        }
            catch(e) {
                alert('bindCallBackResult_Message'+e.message);
            }
        }
        
        
        function bindMsgTable(objTable,objData) { 
            if (objData == null) { return; }
                  										
		    // del rows                        
		    for(var i=objTable.rows.length - 1; i >= 0; i--) {				
			    objTable.deleteRow(i);				
		    }
		    
		    // readd rows
//		    var headRow = objTable.insertRow(objTable.rows.length);
//		    var headCell = headRow.insertCell(headRow.cells.length);
//		    headCell.className = "TD_headrow_style";
		  
            for(var i = 0; i < objData.length; i++) {                      
                var userID = objData[i].UserID;
                  
                var beginTime = objData[i].BeginTime;
                var endTime = objData[i].EndTime;
                var comments = objData[i].Comments;

                
                var elementRow = objTable.insertRow(objTable.rows.length);
		        elementRow.id = "msgRow" + i;
		        
		        //房间
                var elementCol = elementRow.insertCell(elementRow.cells.length);
                elementCol.width="10%";
                elementCol.align="center";
               
                elementCol.innerHTML=userID;
                //开始时间

                var elementCol = elementRow.insertCell(elementRow.cells.length);
               // elementCol.setAttribute("style","width: 10%;");
                elementCol.width="10%";
                elementCol.align="center";
                elementCol.innerHTML=beginTime;
                //结束时间

                var elementCol = elementRow.insertCell(elementRow.cells.length);
               // elementCol.setAttribute("style","width: 10%;");
                elementCol.width="10%";
                elementCol.align="center";
                //elementCol.className = "GridView_item_left"; 
                elementCol.innerHTML=endTime;
                //事件

                var elementCol = elementRow.insertCell(elementRow.cells.length);
                elementCol.width="60%";
          
                elementCol.align="center"; 
                elementCol.innerHTML=comments;
     
                //发送
                var elementCol = elementRow.insertCell(elementRow.cells.length);
               // elementCol.setAttribute("style","width: 5%;");
                elementCol.width="10%";
                elementCol.align="center";

                elementLink = document.createElement("A");
                elementLink.setAttribute("id", "hre" + i);                
                elementLink.setAttribute("href", "#");  
      
                elementLink.onclick=function(){
                if(confirm("是否发送？"))
                {
                    if (!theForm.onsubmit || (theForm.onsubmit() != false))
                    {
                        window.document.getElementById('<%=hidSendFlg.ClientID%>').value="TRUE";
                        window.document.getElementById('<%=hidUserID.ClientID%>').value=userID;
                        window.document.getElementById('<%=hidBeginTime.ClientID%>').value=beginTime;
                        window.document.getElementById('<%=hidComments.ClientID%>').value=comments;
                        
                         theForm.submit();
                    }
                    
                }
                
                    
                
                };
                
                var elementLinkImg = document.createElement("IMG");
                elementLinkImg.setAttribute("id", "imgd" + i);                
                elementLinkImg.setAttribute("src", "../../images/edit.jpg");     
                elementLinkImg.border=0;
                
                elementLink.appendChild(elementLinkImg);

                
                
                
                 
             
     
                elementCol.appendChild(elementLink);
                
                

            }
        }
        
      
</script>
     <table width="100%">
            <tr>
                <td align="left" >
                <script language="javascript" type="text/javascript">
                                        (new TitleBar('SearchBar', '当前事件')).showBar();
                            </script>
                </td>
            </tr>
             <tr>
                <td >
                <table class="GridView_table" cellspacing="0" id="Table1" border="0" style="width:100%">
                    <tr>
                        <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                            房间号</th>
                        <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                            开始时间</th>
                        <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                        结束时间</th>
                        <th class="GridView_head_grayblue" scope="col" style="width: 60%;">
                        事件</th>
                        <th class="GridView_head_grayblue" scope="col" style="width: 10%;">
                        发送</th>
      
                       
                    </tr>
                  </table>
                  <table id="tbAlarm" style="width:100%">
                  </table>
         
                </td>
            </tr>
            <tr>
                <td align="left" >
                <script language="javascript" type="text/javascript">
                                        (new TitleBar('SearchBar', '历史事件')).showBar();
                            </script>
                </td>
            </tr>
            <tr>
                <td >
               <asp:GridView ID="GridView1" runat="server" CssClass="GridView_table" AutoGenerateColumns="False"  Width="100%"
                            BorderWidth="0px" AllowPaging="True"  OnPageIndexChanging="GridView1_PageIndexChanging">
                            <Columns>
                                
                                <asp:BoundField HeaderText="房间号" DataField="UserID">
                                    <ItemStyle CssClass="GridView_item_center"  />
                                    <HeaderStyle CssClass="GridView_head_grayblue" Width="20%" />
                                </asp:BoundField>
                                <asp:BoundField HeaderText="开始时间" DataField="BeginTime">
                                    <ItemStyle CssClass="GridView_item_center"  />
                                    <HeaderStyle CssClass="GridView_head_grayblue" Width="20%" />
                                </asp:BoundField>
                                <asp:BoundField HeaderText="结束时间" DataField="EndTime">
                                    <ItemStyle CssClass="GridView_item_center"  />
                                    <HeaderStyle CssClass="GridView_head_grayblue" Width="20%" />
                                </asp:BoundField>
                                <asp:BoundField HeaderText="事件" DataField="Comments">
                                    <ItemStyle CssClass="GridView_item_center"  />
                                    <HeaderStyle CssClass="GridView_head_grayblue" Width="40%" />
                                </asp:BoundField>
                               
                            </Columns>
                            <PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                        </asp:GridView>
                </td>
            </tr>
     </table>
   <asp:HiddenField ID="hidSendFlg" runat="server"  Value="FALSE"/>
   <asp:HiddenField ID="hidUserID" runat="server" />
   <asp:HiddenField ID="hidBeginTime" runat="server" />
   <asp:HiddenField ID="hidComments" runat="server" />
</asp:Content>